home *** CD-ROM | disk | FTP | other *** search
/ Enciclopedia Del Perro / Enciclopedia Del Perro.iso / win / tfw115c1 / tfw.5 / DDE_DEMO.SLT < prev    next >
Text File  |  1996-04-15  |  4KB  |  110 lines

  1. /****************************************************************/
  2. /*                                                              */
  3. /*  Demo of how to use DDE (Dynamic Data Exchange) in your      */
  4. /*  scripts.  This sample links to a MS Word document.          */
  5. /*                                                              */
  6. /*                   Copyright 1995 deltaComm Development, Inc. */
  7. /*                                                              */
  8. /****************************************************************/
  9.  
  10. #const BUFFSIZE 255
  11. main()
  12. {
  13.   int DDEConv,
  14.       x;
  15.   str Buff[BUFFSIZE],
  16.       Buff2[10];
  17.  
  18.   // Connect to Word for Windows using the System topic
  19.   // so we can find out more info about what it provides.
  20.  
  21.   DDEConv = DDEInitiate("WINWORD", "SYSTEM");
  22.  
  23.   if (DDEConv > 0) {                         // DDE conversation established.
  24.     prints("Connected...");
  25.     prints("");
  26.  
  27.     // SysItems returns a list of all items in the System topic
  28.     // Each item in the string is separated by a tab (ASCII 9)
  29.     // character.  For our purposes, will just display the string.
  30.  
  31.     prints("Items available in the SYSTEM topic are:");
  32.  
  33.     if (DDERequest(DDEConv, "SysItems", Buff))
  34.       prints(buff);
  35.     else
  36.       prints("Could not retrieve items.");
  37.     prints("");
  38.  
  39.     // Topics returns a list of available topics.  Tab delimited
  40.     // in the same manner as the SysItems topic.
  41.  
  42.     prints("Topics available in the server are:");
  43.  
  44.     if (DDERequest(DDEConv, "Topics", Buff))
  45.       prints(buff);
  46.     else
  47.       prints("Could not retrieve topics.");
  48.     prints("");
  49.  
  50.     // close the DDE conversation.
  51.  
  52.     DDETerminate(DDEConv);
  53.     prints("DDE Connection closed.");
  54.    }
  55.   else                         // DDE conversation could not be established.
  56.     prints("Could not connect.");
  57.  
  58.   prints("");
  59.  
  60.   // Connect to Fax software and add an attachment to current fax
  61.  
  62.   DDEConv = DDEInitiate("FAXMNG", "CONTROL");
  63.   if (DDEConv > 0) {                           // DDE conversation established.
  64.     prints("Connected...");
  65.     prints("");
  66.  
  67.     DDEPoke(DDEConv, "SendFax", "attach(^"C:\TFW\SCRIPTS\EXAMPLE.SLT^")");
  68.  
  69.     // close the DDE conversation.
  70.  
  71.     prints("DDE Connection closed.");
  72.    }
  73.   else                        // DDE conversation could not be established.
  74.     prints("Could not connect.");
  75.  
  76.   prints("");
  77.  
  78.   // Start a conversation with Program Manager
  79.  
  80.   DDEConv = DDEInitiate("PROGMAN", "PROGMAN");
  81.   if (DDEConv > 0) {
  82.     prints("Connected...");
  83.  
  84.     // Create a new group in Program Manager
  85.  
  86.     prints("Creating new group...");
  87.     DDEExecute(DDEConv, "[CreateGroup(^"SALT Scripts^")]");
  88.  
  89.     // Make sure that the new group is open
  90.  
  91.     prints("Making sure new group is visible...");
  92.     DDEExecute(DDEConv, "[ShowGroup(^"SALT Scripts^", 1)]");
  93.  
  94.  
  95.     // Add a program item to the new group.  The file should exist or this
  96.     // may fail.  Note the use of  ^"  below.  Those are embedded "
  97.     // characters.  The string that is sent to Program Manager looks like:
  98.     //   [AddItem("C:\TFW\SCRIPTS\EXAMPLE.SLC","Example Script","C:\TFW\TELIX.EXE",0)]
  99.     // The first parameter is the application filename.  Second is the title
  100.     // for Program Manager.  Third is the icon filename.  Fourth is which
  101.     // icon to use (first is 0).
  102.  
  103.     prints("Adding example script.");
  104.     DDEExecute(DDEConv, "[AddItem(^"C:\TFW\SCRIPTS\EXAMPLE.SLC^",^"Example Script^",^"C:\TFW\TELIX.EXE^",0)]");
  105.    }
  106.   DDETerminateall();
  107.   prints("");
  108. }
  109.  
  110.